/*
 * @Description: 
 * @Author: paddies
 * @Date: 2024-11-28 11:23:04
 * @LastEditors: paddies
 * @LastEditTime: 2025-09-16 20:21:45
 * @FilePath: /luntai-user-app/Users/paddies/Desktop/code/A-team/luntai/shared_components/lib/luntai-components/build-some-pay-panel/buildSomePayPanel.dart
 */

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:promise/promise.dart';
import 'package:shared_components/build-button/buildButton.dart';
import 'package:shared_components/build-common/buildCommon.dart';
import 'package:shared_components/build-image/buildImage.dart';
import 'package:shared_components/build-input-password/buildInputPassword.dart';
import 'package:shared_components/build-line/buildLine.dart';
import 'package:shared_components/build-radio-group/buildRadioGroup.dart';
import 'package:shared_components/luntai-components/build-change-count/buildChangeCount.dart';
import 'package:shared_components/utils/global_prefs.dart';

Color activeColor = const Color(0xffe53627);
Color defaultColor = const Color(0xffd9d9d9);
Color activeBgColor = const Color(0xfffceeef);

Future buildSomePayPanel(
    {List list = const [],
    String type = 'joinIn',
    String auditFee = '',
    String saleAmount = '',
    String ensureFee = '',
    String ensureFeeId = '',
    String repairOrderNumber = '',
    String reducePrice = '0',
    List<dynamic> appendDetails = const [],
    Function? doGetOrderFee,
    Function? doOtherSubmit,
    Function? okCallBack,
    Function? passwordOkCallBack,
    String title = "支付入驻费"}) async {
  final double width = MediaQuery.of(Get.overlayContext!).size.width;
  final double bottomHeight = MediaQuery.of(Get.overlayContext!).padding.bottom;
  var payType = "YE".obs;
  var free = "0.0".obs;
  var count = 1.obs;
  var isRead = false.obs;
  //打赏支付
  if (type == 'reword') {
    calculationFree() {
      if (list.isNotEmpty) {
        var p = list[0]["price"] ?? "0";
        free.value = showText(double.parse(p) * count.value);
      }
    }

    calculationFree();

    return Get.bottomSheet(
        WillPopScope(
            onWillPop: () async => false, //重点此举
            child: Container(
                decoration: const BoxDecoration(
                  color: Colors.transparent,
                  borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(20.0),
                      topRight: Radius.circular(20.0)), //圆角
                ),
                child: Obx(() => Column(
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: [
                        Container(
                          width: double.infinity,
                          height: 600,
                          color: Colors.white,
                          child: Column(
                            children: [
                              Container(
                                width: double.infinity,
                                padding: const EdgeInsets.only(
                                    left: 15, right: 15, top: 15, bottom: 15),
                                child: Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text(
                                      title,
                                      style: TextStyle(
                                          fontSize: 20,
                                          fontWeight: FontWeight.bold),
                                    ),
                                    GestureDetector(
                                      onTap: () {
                                        GlobalPrefs.saveValue(
                                            "hasWindow", "NO");
                                        Get.back();
                                      },
                                      child: const Text(
                                        "取消",
                                        style: TextStyle(
                                            color: Color(0xffaaaaaa),
                                            fontSize: 16),
                                      ),
                                    )
                                  ],
                                ),
                              ),
                              Expanded(
                                  child: Container(
                                      width: double.infinity,
                                      height: double.infinity,
                                      color: Colors.white,
                                      child: SingleChildScrollView(
                                        child: Column(
                                          children: [
                                            ...list.map((e) {
                                              return Container(
                                                width: double.infinity,
                                                height: 40,
                                                color: Colors.transparent,
                                                padding: EdgeInsets.only(
                                                    left: 10, right: 10),
                                                child: Row(
                                                  children: [
                                                    // Container(
                                                    //   width: 80,
                                                    //   height: double.infinity,
                                                    //   color: Colors.transparent,
                                                    //   child: buildImage(
                                                    //       type: "ClipRect",
                                                    //       url: showText(
                                                    //           e["url"])),
                                                    // ),
                                                    Expanded(
                                                        child: Container(
                                                      width: double.infinity,
                                                      height: double.infinity,
                                                      alignment:
                                                          Alignment.centerLeft,
                                                      color: Colors.transparent,
                                                      padding: EdgeInsets.only(
                                                          left: 10, right: 10),
                                                      child: Row(
                                                        crossAxisAlignment:
                                                            CrossAxisAlignment
                                                                .center,
                                                        mainAxisAlignment:
                                                            MainAxisAlignment
                                                                .spaceBetween,
                                                        children: [
                                                          Container(
                                                            // width:
                                                            // double.infinity,
                                                            child: Text(
                                                              showText(
                                                                  e["name"]),
                                                              maxLines: 2,
                                                              style: TextStyle(
                                                                  fontSize: 14,
                                                                  fontWeight:
                                                                      FontWeight
                                                                          .bold),
                                                              overflow:
                                                                  TextOverflow
                                                                      .ellipsis,
                                                            ),
                                                          ),
                                                          Row(
                                                            children: [
                                                              Text(
                                                                "¥",
                                                                style: TextStyle(
                                                                    fontWeight:
                                                                        FontWeight
                                                                            .bold),
                                                              ),
                                                              Text(
                                                                e['price'],
                                                                style: TextStyle(
                                                                    fontSize:
                                                                        17,
                                                                    fontWeight:
                                                                        FontWeight
                                                                            .bold),
                                                              )
                                                            ],
                                                          )
                                                          // Row(
                                                          //   mainAxisAlignment:
                                                          //       MainAxisAlignment
                                                          //           .spaceBetween,
                                                          //   children: [
                                                          //     Text(
                                                          //       "x1",
                                                          //       style: TextStyle(
                                                          //           color: Color(
                                                          //               0xff888888)),
                                                          //     ),
                                                          //     Row(
                                                          //       children: [
                                                          //         Text(
                                                          //           "价格",
                                                          //           style: TextStyle(
                                                          //               fontSize:
                                                          //                   14,
                                                          //               color: Color(
                                                          //                   0xff888888)),
                                                          //         ),
                                                          //         Text(
                                                          //           "¥",
                                                          //           style: TextStyle(
                                                          //               fontWeight:
                                                          //                   FontWeight.bold),
                                                          //         ),
                                                          //         Text(
                                                          //           e['price'],
                                                          //           style: TextStyle(
                                                          //               fontSize:
                                                          //                   17,
                                                          //               fontWeight:
                                                          //                   FontWeight.bold),
                                                          //         )
                                                          //       ],
                                                          //     )
                                                          //   ],
                                                          // )
                                                        ],
                                                      ),
                                                    ))
                                                  ],
                                                ),
                                              );
                                            }).toList(),
                                            // Container(
                                            //   width: double.infinity,
                                            //   padding: EdgeInsets.all(15),
                                            //   child: Text(
                                            //     "由于你的销售累计金额已达 " +
                                            //         saleAmount +
                                            //         " 元需要补交 " +
                                            //         ensureFee +
                                            //         "元保证金",
                                            //     style: TextStyle(
                                            //         color: Color(0xff969696)),
                                            //   ),
                                            // ),
                                            const SizedBox(
                                              height: 8,
                                            ),

                                            // Container(
                                            //   width: double.infinity,
                                            //   height: 50,
                                            //   color: Colors.transparent,
                                            //   padding:
                                            //       const EdgeInsets.only(left: 10, right: 10),
                                            //   child: const Row(
                                            //     mainAxisAlignment:
                                            //         MainAxisAlignment.spaceBetween,
                                            //     children: [
                                            //       Text(
                                            //         "证件审核费",
                                            //         style: TextStyle(
                                            //             fontSize: 16,
                                            //             fontWeight: FontWeight.bold),
                                            //       ),
                                            //       Text(
                                            //         "¥500",
                                            //         style: TextStyle(
                                            //             fontSize: 16,
                                            //             fontWeight: FontWeight.bold),
                                            //       )
                                            //     ],
                                            //   ),
                                            // ),
                                            // buildLine(),
                                            // Container(
                                            //   width: double.infinity,
                                            //   height: 50,
                                            //   color: Colors.transparent,
                                            //   padding: const EdgeInsets.only(
                                            //       left: 10, right: 10),
                                            //   child: Row(
                                            //     mainAxisAlignment:
                                            //         MainAxisAlignment
                                            //             .spaceBetween,
                                            //     children: [
                                            //       Text(
                                            //         "保证金",
                                            //         style: TextStyle(
                                            //             fontSize: 16,
                                            //             fontWeight:
                                            //                 FontWeight.bold),
                                            //       ),
                                            //       Text(
                                            //         "¥" + ensureFee,
                                            //         style: TextStyle(
                                            //             fontSize: 16,
                                            //             fontWeight:
                                            //                 FontWeight.bold),
                                            //       )
                                            //     ],
                                            //   ),
                                            // ),
                                            buildLine(),
                                            SizedBox(
                                              height: 10,
                                            ),
                                            // Container(
                                            //   width: double.infinity,
                                            //   padding: EdgeInsets.only(
                                            //       left: 10, right: 10),
                                            //   child: Row(
                                            //     mainAxisAlignment:
                                            //         MainAxisAlignment
                                            //             .spaceBetween,
                                            //     children: [
                                            //       Text(
                                            //         "购买数量",
                                            //         style: TextStyle(
                                            //             fontSize: 16,
                                            //             fontWeight:
                                            //                 FontWeight.bold),
                                            //       ),
                                            //       Expanded(
                                            //           child: Container(
                                            //         width: double.infinity,
                                            //         alignment:
                                            //             Alignment.centerRight,
                                            //         color: Colors.transparent,
                                            //         child: Row(
                                            //           mainAxisAlignment:
                                            //               MainAxisAlignment.end,
                                            //           children: [
                                            //             GestureDetector(
                                            //               onTap: () {
                                            //                 count.value -= 1;
                                            //                 if (count.value <=
                                            //                     0) {
                                            //                   count.value = 1;
                                            //                 }

                                            //                 calculationFree();
                                            //               },
                                            //               child: Container(
                                            //                   width: 50,
                                            //                   height: 30,
                                            //                   color: Colors
                                            //                       .transparent,
                                            //                   child: Icon(
                                            //                     Icons.remove,
                                            //                     size: 20,
                                            //                   )),
                                            //             ),
                                            //             GestureDetector(
                                            //               onTap: () {
                                            //                 //弹出输入框修改
                                            //                 buildChangeCount(
                                            //                     count:
                                            //                         count.value,
                                            //                     onSubmit:
                                            //                         (v) async {
                                            //                       count.value =
                                            //                           v;
                                            //                       calculationFree();
                                            //                     });
                                            //               },
                                            //               child: Container(
                                            //                 width: 100,
                                            //                 height: 30,
                                            //                 color: Colors
                                            //                     .transparent,
                                            //                 alignment: Alignment
                                            //                     .center,
                                            //                 child: Text(
                                            //                   showText(
                                            //                       count.value),
                                            //                   style: TextStyle(
                                            //                       fontWeight:
                                            //                           FontWeight
                                            //                               .bold),
                                            //                 ),
                                            //               ),
                                            //             ),
                                            //             GestureDetector(
                                            //               onTap: () {
                                            //                 count.value += 1;
                                            //                 calculationFree();
                                            //               },
                                            //               child: Container(
                                            //                 width: 50,
                                            //                 height: 30,
                                            //                 alignment: Alignment
                                            //                     .center,
                                            //                 color: Colors
                                            //                     .transparent,
                                            //                 child: Icon(
                                            //                   Icons.add,
                                            //                   size: 20,
                                            //                 ),
                                            //               ),
                                            //             )
                                            //           ],
                                            //         ),
                                            //       ))
                                            //     ],
                                            //   ),
                                            // ),
                                            // SizedBox(
                                            //   height: 20,
                                            // ),

                                            Container(
                                              width: double.infinity,
                                              // height: 50,
                                              color: Colors.transparent,
                                              padding: const EdgeInsets.only(
                                                  left: 10, right: 10),
                                              child: Text(
                                                "请选择支付方式",
                                                style: TextStyle(
                                                    fontSize: 16,
                                                    fontWeight:
                                                        FontWeight.bold),
                                              ),
                                            ),
                                            SizedBox(
                                              height: 20,
                                            ),
                                            Container(
                                              width: double.infinity,
                                              height: 50,
                                              color: Colors.transparent,
                                              padding: const EdgeInsets.only(
                                                  left: 10, right: 10),
                                              child: buildNewRadioGrou(
                                                  list: [
                                                    {
                                                      "label": "余额支付",
                                                      "icon": "yue",
                                                      "value": "YE"
                                                    },
                                                    {
                                                      "label": "支付宝",
                                                      "icon": "zhifubao",
                                                      "value": "ALI"
                                                    },
                                                    {
                                                      "label": "微信支付",
                                                      "icon": "weixin",
                                                      "value": "WX"
                                                    }
                                                  ],
                                                  widthFactor: 3,
                                                  activeValue: payType.value,
                                                  onChange: (value) {
                                                    print("99999");
                                                    payType.value = value;
                                                    // onChangePayType(value)
                                                    // payType.value = value;
                                                    // if (onChange !=
                                                    //     null) {
                                                    //   onChange(value);
                                                    // }
                                                  }),
                                            ),
                                            SizedBox(
                                              height: 30,
                                            ),
                                            GestureDetector(
                                              onTap: () {
                                                isRead.value = !isRead.value;
                                              },
                                              child: Container(
                                                width: double.infinity,
                                                height: 50,
                                                alignment: Alignment.centerLeft,
                                                padding: const EdgeInsets.only(
                                                    left: 15, right: 15),
                                                color: Colors.transparent,
                                                child: Row(
                                                  children: [
                                                    // Container(
                                                    //   width: 18,
                                                    //   height: 18,
                                                    //   alignment:
                                                    //       Alignment.center,
                                                    //   decoration: BoxDecoration(
                                                    //       color: isRead.value
                                                    //           ? Colors.red
                                                    //           : Color(
                                                    //               0xffe6e0eb),
                                                    //       borderRadius:
                                                    //           BorderRadius.all(
                                                    //               Radius
                                                    //                   .circular(
                                                    //                       50))),
                                                    //   child: const Icon(
                                                    //     Icons.check,
                                                    //     size: 12,
                                                    //     color: Colors.white,
                                                    //   ),
                                                    // ),
                                                    // const SizedBox(
                                                    //   width: 10,
                                                    // ),
                                                    // const Text("已阅读并同意"),
                                                    // const Text(
                                                    //   "APP 协议",
                                                    //   style: TextStyle(
                                                    //       color: Color(
                                                    //           0xff3c65f6)),
                                                    // ),
                                                    // const Text("和"),
                                                    // const Text(
                                                    //   "信息保护政策",
                                                    //   style: TextStyle(
                                                    //       color: Color(
                                                    //           0xff3c65f6)),
                                                    // )
                                                  ],
                                                ),
                                              ),
                                            )
                                          ],
                                        ),
                                      ))),
                              Container(
                                width: double.infinity,
                                height: 70,
                                color: Colors.white,
                                child: Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Expanded(
                                        child: Container(
                                      width: double.infinity,
                                      height: double.infinity,
                                      child: Row(
                                        children: [
                                          SizedBox(
                                            width: 10,
                                          ),
                                          Text(
                                            "总计",
                                            style: TextStyle(
                                                color: Color(0xff919191)),
                                          ),
                                          SizedBox(
                                            width: 5,
                                          ),
                                          Text(
                                            "¥",
                                          ),
                                          Text(
                                            free.value,
                                            style: TextStyle(
                                                fontSize: 16,
                                                fontWeight: FontWeight.bold),
                                          )
                                        ],
                                      ),
                                    )),
                                    Container(
                                      width: 120,
                                      padding: const EdgeInsets.only(
                                          top: 13, bottom: 13, right: 10),
                                      height: double.infinity,
                                      child: buildButton(
                                          title: "立即支付",
                                          borderRadius: 10,
                                          onClick: () async {
                                            // if (!isRead.value) {
                                            //   EasyLoading.showToast(
                                            //       "请阅读并勾选同意协议");
                                            //   return;
                                            // }
                                            if (list.length == 0) {
                                              return;
                                            }
                                            if (doOtherSubmit != null) {
                                              // var id = ensureFeeId;
                                              var res = await doOtherSubmit({
                                                "orderNo": ensureFeeId,
                                                "rewordPrice": free.value,
                                                "totalPrice": free.value
                                              });
                                              print("下单返回");
                                              print(res);

                                              if (payType.value == 'YE') {
                                                // 校验支付密码
                                                buildInputPassword(
                                                    payType: "余额支付",
                                                    price: free.value,
                                                    onSuccess: (value) async {
                                                      print("输入的密码是===");
                                                      print(value);
                                                      if (passwordOkCallBack !=
                                                          null) {
                                                        passwordOkCallBack(
                                                            payType.value,
                                                            free.value,
                                                            res,
                                                            value);
                                                      }
                                                    });

                                                GlobalPrefs.saveValue(
                                                    "hasWindow", "NO");

                                                return;
                                              }

                                              if (okCallBack != null) {
                                                okCallBack(payType.value,
                                                    free.value, res);
                                              }

                                              GlobalPrefs.saveValue(
                                                  "hasWindow", "NO");
                                            }
                                          },
                                          colors: [activeColor, activeColor]),
                                    )
                                  ],
                                ),
                              ),
                              Container(
                                width: double.infinity,
                                height: bottomHeight,
                                color: Colors.white,
                              )
                            ],
                          ),
                        )
                      ],
                    )))),
        isDismissible: false, // 设置为false以禁止点击其他区域关闭
        enableDrag: false, // 设置为false以禁止拖动关闭
        isScrollControlled: true,
        // barrierColor: Colors.red,
        ignoreSafeArea: false,
        useRootNavigator: true);
  }
  if (type == 'gift') {
    calculationFree() {
      if (list.isNotEmpty) {
        var p = list[0]["price"] ?? "0";
        free.value = showText(double.parse(p) * count.value);
      }
    }

    calculationFree();

    return Get.bottomSheet(
        WillPopScope(
            onWillPop: () async => false, //重点此举
            child: Container(
                decoration: const BoxDecoration(
                  color: Colors.transparent,
                  borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(20.0),
                      topRight: Radius.circular(20.0)), //圆角
                ),
                child: Obx(() => Column(
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: [
                        Container(
                          width: double.infinity,
                          height: 600,
                          color: Colors.white,
                          child: Column(
                            children: [
                              Container(
                                width: double.infinity,
                                padding: const EdgeInsets.only(
                                    left: 15, right: 15, top: 15, bottom: 15),
                                child: Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text(
                                      title,
                                      style: TextStyle(
                                          fontSize: 20,
                                          fontWeight: FontWeight.bold),
                                    ),
                                    GestureDetector(
                                      onTap: () {
                                        GlobalPrefs.saveValue(
                                            "hasWindow", "NO");
                                        Get.back();
                                      },
                                      child: const Text(
                                        "取消",
                                        style: TextStyle(
                                            color: Color(0xffaaaaaa),
                                            fontSize: 16),
                                      ),
                                    )
                                  ],
                                ),
                              ),
                              Expanded(
                                  child: Container(
                                      width: double.infinity,
                                      height: double.infinity,
                                      color: Colors.white,
                                      child: SingleChildScrollView(
                                        child: Column(
                                          children: [
                                            ...list.map((e) {
                                              return Container(
                                                width: double.infinity,
                                                height: 80,
                                                padding: EdgeInsets.only(
                                                    left: 10, right: 10),
                                                child: Row(
                                                  children: [
                                                    Container(
                                                      width: 80,
                                                      height: double.infinity,
                                                      color: Colors.transparent,
                                                      child: buildImage(
                                                          type: "ClipRect",
                                                          url: showText(
                                                              e["url"])),
                                                    ),
                                                    Expanded(
                                                        child: Container(
                                                      width: double.infinity,
                                                      height: double.infinity,
                                                      color: Colors.transparent,
                                                      padding: EdgeInsets.only(
                                                          left: 10, right: 10),
                                                      child: Column(
                                                        mainAxisAlignment:
                                                            MainAxisAlignment
                                                                .spaceBetween,
                                                        children: [
                                                          Container(
                                                            width:
                                                                double.infinity,
                                                            child: Text(
                                                              showText(
                                                                  e["name"]),
                                                              maxLines: 2,
                                                              style: TextStyle(
                                                                  fontSize: 14,
                                                                  fontWeight:
                                                                      FontWeight
                                                                          .bold),
                                                              overflow:
                                                                  TextOverflow
                                                                      .ellipsis,
                                                            ),
                                                          ),
                                                          Row(
                                                            mainAxisAlignment:
                                                                MainAxisAlignment
                                                                    .spaceBetween,
                                                            children: [
                                                              Text(
                                                                "x1",
                                                                style: TextStyle(
                                                                    color: Color(
                                                                        0xff888888)),
                                                              ),
                                                              Row(
                                                                children: [
                                                                  Text(
                                                                    "价格",
                                                                    style: TextStyle(
                                                                        fontSize:
                                                                            14,
                                                                        color: Color(
                                                                            0xff888888)),
                                                                  ),
                                                                  Text(
                                                                    "¥",
                                                                    style: TextStyle(
                                                                        fontWeight:
                                                                            FontWeight.bold),
                                                                  ),
                                                                  Text(
                                                                    e['price'],
                                                                    style: TextStyle(
                                                                        fontSize:
                                                                            17,
                                                                        fontWeight:
                                                                            FontWeight.bold),
                                                                  )
                                                                ],
                                                              )
                                                            ],
                                                          )
                                                        ],
                                                      ),
                                                    ))
                                                  ],
                                                ),
                                              );
                                            }).toList(),
                                            // Container(
                                            //   width: double.infinity,
                                            //   padding: EdgeInsets.all(15),
                                            //   child: Text(
                                            //     "由于你的销售累计金额已达 " +
                                            //         saleAmount +
                                            //         " 元需要补交 " +
                                            //         ensureFee +
                                            //         "元保证金",
                                            //     style: TextStyle(
                                            //         color: Color(0xff969696)),
                                            //   ),
                                            // ),
                                            const SizedBox(
                                              height: 8,
                                            ),

                                            // Container(
                                            //   width: double.infinity,
                                            //   height: 50,
                                            //   color: Colors.transparent,
                                            //   padding:
                                            //       const EdgeInsets.only(left: 10, right: 10),
                                            //   child: const Row(
                                            //     mainAxisAlignment:
                                            //         MainAxisAlignment.spaceBetween,
                                            //     children: [
                                            //       Text(
                                            //         "证件审核费",
                                            //         style: TextStyle(
                                            //             fontSize: 16,
                                            //             fontWeight: FontWeight.bold),
                                            //       ),
                                            //       Text(
                                            //         "¥500",
                                            //         style: TextStyle(
                                            //             fontSize: 16,
                                            //             fontWeight: FontWeight.bold),
                                            //       )
                                            //     ],
                                            //   ),
                                            // ),
                                            // buildLine(),
                                            // Container(
                                            //   width: double.infinity,
                                            //   height: 50,
                                            //   color: Colors.transparent,
                                            //   padding: const EdgeInsets.only(
                                            //       left: 10, right: 10),
                                            //   child: Row(
                                            //     mainAxisAlignment:
                                            //         MainAxisAlignment
                                            //             .spaceBetween,
                                            //     children: [
                                            //       Text(
                                            //         "保证金",
                                            //         style: TextStyle(
                                            //             fontSize: 16,
                                            //             fontWeight:
                                            //                 FontWeight.bold),
                                            //       ),
                                            //       Text(
                                            //         "¥" + ensureFee,
                                            //         style: TextStyle(
                                            //             fontSize: 16,
                                            //             fontWeight:
                                            //                 FontWeight.bold),
                                            //       )
                                            //     ],
                                            //   ),
                                            // ),
                                            buildLine(),
                                            SizedBox(
                                              height: 10,
                                            ),
                                            Container(
                                              width: double.infinity,
                                              padding: EdgeInsets.only(
                                                  left: 10, right: 10),
                                              child: Row(
                                                mainAxisAlignment:
                                                    MainAxisAlignment
                                                        .spaceBetween,
                                                children: [
                                                  Text(
                                                    "购买数量",
                                                    style: TextStyle(
                                                        fontSize: 16,
                                                        fontWeight:
                                                            FontWeight.bold),
                                                  ),
                                                  Expanded(
                                                      child: Container(
                                                    width: double.infinity,
                                                    alignment:
                                                        Alignment.centerRight,
                                                    color: Colors.transparent,
                                                    child: Row(
                                                      mainAxisAlignment:
                                                          MainAxisAlignment.end,
                                                      children: [
                                                        GestureDetector(
                                                          onTap: () {
                                                            count.value -= 1;
                                                            if (count.value <=
                                                                0) {
                                                              count.value = 1;
                                                            }

                                                            calculationFree();
                                                          },
                                                          child: Container(
                                                              width: 50,
                                                              height: 30,
                                                              color: Colors
                                                                  .transparent,
                                                              child: Icon(
                                                                Icons.remove,
                                                                size: 20,
                                                              )),
                                                        ),
                                                        GestureDetector(
                                                          onTap: () {
                                                            //弹出输入框修改
                                                            buildChangeCount(
                                                                count:
                                                                    count.value,
                                                                onSubmit:
                                                                    (v) async {
                                                                  count.value =
                                                                      v;
                                                                  calculationFree();
                                                                });
                                                          },
                                                          child: Container(
                                                            width: 100,
                                                            height: 30,
                                                            color: Colors
                                                                .transparent,
                                                            alignment: Alignment
                                                                .center,
                                                            child: Text(
                                                              showText(
                                                                  count.value),
                                                              style: TextStyle(
                                                                  fontWeight:
                                                                      FontWeight
                                                                          .bold),
                                                            ),
                                                          ),
                                                        ),
                                                        GestureDetector(
                                                          onTap: () {
                                                            count.value += 1;
                                                            calculationFree();
                                                          },
                                                          child: Container(
                                                            width: 50,
                                                            height: 30,
                                                            alignment: Alignment
                                                                .center,
                                                            color: Colors
                                                                .transparent,
                                                            child: Icon(
                                                              Icons.add,
                                                              size: 20,
                                                            ),
                                                          ),
                                                        )
                                                      ],
                                                    ),
                                                  ))
                                                ],
                                              ),
                                            ),
                                            SizedBox(
                                              height: 20,
                                            ),

                                            Container(
                                              width: double.infinity,
                                              // height: 50,
                                              color: Colors.transparent,
                                              padding: const EdgeInsets.only(
                                                  left: 10, right: 10),
                                              child: Text(
                                                "请选择支付方式",
                                                style: TextStyle(
                                                    fontSize: 16,
                                                    fontWeight:
                                                        FontWeight.bold),
                                              ),
                                            ),
                                            SizedBox(
                                              height: 20,
                                            ),
                                            Container(
                                              width: double.infinity,
                                              height: 50,
                                              color: Colors.transparent,
                                              padding: const EdgeInsets.only(
                                                  left: 10, right: 10),
                                              child: buildNewRadioGrou(
                                                  list: [
                                                    // {
                                                    //   "label": "微信支付",
                                                    //   "icon": "weixin",
                                                    //   "value": "WX"
                                                    // }
                                                    // {"label": "积分支付", "value": "JF"},
                                                    {
                                                      "label": "余额支付",
                                                      "icon": "yue",
                                                      "value": "YE"
                                                    },
                                                    {
                                                      "label": "支付宝",
                                                      "icon": "zhifubao",
                                                      "value": "ALI"
                                                    },
                                                    {
                                                      "label": "微信支付",
                                                      "icon": "weixin",
                                                      "value": "WX"
                                                    }
                                                  ],
                                                  widthFactor: 3,
                                                  activeValue: payType.value,
                                                  onChange: (value) {
                                                    print("99999");
                                                    payType.value = value;
                                                    // onChangePayType(value)
                                                    // payType.value = value;
                                                    // if (onChange !=
                                                    //     null) {
                                                    //   onChange(value);
                                                    // }
                                                  }),
                                            ),
                                            SizedBox(
                                              height: 30,
                                            ),
                                            GestureDetector(
                                              onTap: () {
                                                isRead.value = !isRead.value;
                                              },
                                              child: Container(
                                                width: double.infinity,
                                                height: 50,
                                                alignment: Alignment.centerLeft,
                                                padding: const EdgeInsets.only(
                                                    left: 15, right: 15),
                                                color: Colors.transparent,
                                                child: Row(
                                                  children: [
                                                    // Container(
                                                    //   width: 18,
                                                    //   height: 18,
                                                    //   alignment:
                                                    //       Alignment.center,
                                                    //   decoration: BoxDecoration(
                                                    //       color: isRead.value
                                                    //           ? Colors.red
                                                    //           : Color(
                                                    //               0xffe6e0eb),
                                                    //       borderRadius:
                                                    //           BorderRadius.all(
                                                    //               Radius
                                                    //                   .circular(
                                                    //                       50))),
                                                    //   child: const Icon(
                                                    //     Icons.check,
                                                    //     size: 12,
                                                    //     color: Colors.white,
                                                    //   ),
                                                    // ),
                                                    // const SizedBox(
                                                    //   width: 10,
                                                    // ),
                                                    // const Text("已阅读并同意"),
                                                    // const Text(
                                                    //   "APP 协议",
                                                    //   style: TextStyle(
                                                    //       color: Color(
                                                    //           0xff3c65f6)),
                                                    // ),
                                                    // const Text("和"),
                                                    // const Text(
                                                    //   "信息保护政策",
                                                    //   style: TextStyle(
                                                    //       color: Color(
                                                    //           0xff3c65f6)),
                                                    // )
                                                  ],
                                                ),
                                              ),
                                            )
                                          ],
                                        ),
                                      ))),
                              Container(
                                width: double.infinity,
                                height: 70,
                                color: Colors.white,
                                child: Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Expanded(
                                        child: Container(
                                      width: double.infinity,
                                      height: double.infinity,
                                      child: Row(
                                        children: [
                                          SizedBox(
                                            width: 10,
                                          ),
                                          Text(
                                            "总计",
                                            style: TextStyle(
                                                color: Color(0xff919191)),
                                          ),
                                          SizedBox(
                                            width: 5,
                                          ),
                                          Text(
                                            "¥",
                                          ),
                                          Text(
                                            free.value,
                                            style: TextStyle(
                                                fontSize: 16,
                                                fontWeight: FontWeight.bold),
                                          )
                                        ],
                                      ),
                                    )),
                                    Container(
                                      width: 120,
                                      padding: const EdgeInsets.only(
                                          top: 13, bottom: 13, right: 10),
                                      height: double.infinity,
                                      child: buildButton(
                                          title: "立即支付",
                                          borderRadius: 10,
                                          onClick: () async {
                                            // if (!isRead.value) {
                                            //   EasyLoading.showToast(
                                            //       "请阅读并勾选同意协议");
                                            //   return;
                                            // }
                                            if (list.length == 0) {
                                              return;
                                            }
                                            if (doOtherSubmit != null) {
                                              // var id = ensureFeeId;
                                              var res = await doOtherSubmit({
                                                "feeItems": list.map((e) {
                                                  return {
                                                    "feeId": e["id"],
                                                    "feeType": "COUPON_GIFT",
                                                    "number": count.value,
                                                    "price": e["price"]
                                                  };
                                                }).toList(),
                                                //  [
                                                //   {
                                                //     "feeId": id,
                                                //     "feeType": "COUPON_GIFT",
                                                //     "price": ensureFee
                                                //   }
                                                // ],
                                                "totalPrice": free.value
                                              });
                                              print("下单返回");
                                              print(res);

                                              if (payType.value == 'YE') {
                                                // 校验支付密码
                                                buildInputPassword(
                                                    payType: "余额支付",
                                                    price: free.value,
                                                    onSuccess: (value) async {
                                                      print("输入的密码是===");
                                                      print(value);
                                                      if (passwordOkCallBack !=
                                                          null) {
                                                        passwordOkCallBack(
                                                            payType.value,
                                                            free.value,
                                                            res,
                                                            value);
                                                      }
                                                    });

                                                GlobalPrefs.saveValue(
                                                    "hasWindow", "NO");

                                                return;
                                              }

                                              if (okCallBack != null) {
                                                okCallBack(payType.value,
                                                    free.value, res);
                                              }

                                              GlobalPrefs.saveValue(
                                                  "hasWindow", "NO");
                                            }
                                          },
                                          colors: [activeColor, activeColor]),
                                    )
                                  ],
                                ),
                              ),
                              Container(
                                width: double.infinity,
                                height: bottomHeight,
                                color: Colors.white,
                              )
                            ],
                          ),
                        )
                      ],
                    )))),
        isDismissible: false, // 设置为false以禁止点击其他区域关闭
        enableDrag: false, // 设置为false以禁止拖动关闭
        isScrollControlled: true,
        // barrierColor: Colors.red,
        ignoreSafeArea: false,
        useRootNavigator: true);
  }
  // String value = await GlobalPrefs.init();
  // if ('ok' == value) {
  var hasWindow = GlobalPrefs.getValue("hasWindow");
  if (hasWindow == 'YES') {
    return;
  }

  GlobalPrefs.saveValue("hasWindow", "YES");
  // }
  if (type == 'joinIn') {
    var payList = [].obs;
    payList.value = list;

    var activeIndex = 0.obs;

    if (doGetOrderFee != null) {
      var id = showText(list[activeIndex.value]["id"]);
      var myFree = await getOrderFree(doGetOrderFee: doGetOrderFee, id: id);
      free.value = showText(myFree);
    }
    return Get.bottomSheet(
        WillPopScope(
            onWillPop: () async => false, //重点此举
            child: Obx(() => Container(
                decoration: const BoxDecoration(
                  color: Colors.transparent,
                  borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(20.0),
                      topRight: Radius.circular(20.0)), //圆角
                ),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    Container(
                      width: double.infinity,
                      height: 600,
                      color: Colors.white,
                      child: Column(
                        children: [
                          Container(
                            width: double.infinity,
                            padding: const EdgeInsets.only(
                                left: 15, right: 15, top: 15, bottom: 15),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Text(
                                  title,
                                  style: TextStyle(
                                      fontSize: 20,
                                      fontWeight: FontWeight.bold),
                                ),
                                GestureDetector(
                                  onTap: () {
                                    GlobalPrefs.saveValue("hasWindow", "NO");
                                    GlobalPrefs.saveValue(
                                        'userCancelJoinIn', 'true');
                                    Get.back();
                                  },
                                  child: const Text(
                                    "取消",
                                    style: TextStyle(
                                        color: Color(0xffaaaaaa), fontSize: 16),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Expanded(
                              child: Container(
                                  width: double.infinity,
                                  height: double.infinity,
                                  color: Colors.white,
                                  child: SingleChildScrollView(
                                    child: Column(
                                      children: [
                                        // 价格
                                        Container(
                                          width: double.infinity,
                                          height: width / 3 + 20,
                                          color: Colors.white,
                                          child: SingleChildScrollView(
                                            scrollDirection: Axis.horizontal,
                                            child: Row(
                                              children: [
                                                ...payList.value
                                                    .asMap()
                                                    .keys
                                                    .map((index) {
                                                  return GestureDetector(
                                                    onTap: () async {
                                                      activeIndex.value = index;
                                                      if (doGetOrderFee !=
                                                          null) {
                                                        var id = showText(list[
                                                            activeIndex
                                                                .value]["id"]);
                                                        var myFree =
                                                            await getOrderFree(
                                                                doGetOrderFee:
                                                                    doGetOrderFee,
                                                                id: id);
                                                        free.value =
                                                            showText(myFree);
                                                      }
                                                    },
                                                    child: Container(
                                                      width: width / 3,
                                                      height: double.infinity,
                                                      color: Colors.white,
                                                      padding:
                                                          const EdgeInsets.all(
                                                              5),
                                                      child: Column(
                                                        children: [
                                                          Expanded(
                                                              child: Container(
                                                                  width: double
                                                                      .infinity,
                                                                  height: double
                                                                      .infinity,
                                                                  decoration: BoxDecoration(
                                                                      color: activeIndex.value ==
                                                                              index
                                                                          ? activeBgColor
                                                                          : Colors
                                                                              .white,
                                                                      border: Border(
                                                                          left: BorderSide(
                                                                              width:
                                                                                  1.0,
                                                                              color: activeIndex.value == index
                                                                                  ? activeColor
                                                                                  : defaultColor),
                                                                          right: BorderSide(
                                                                              width:
                                                                                  1.0,
                                                                              color: activeIndex.value == index
                                                                                  ? activeColor
                                                                                  : defaultColor),
                                                                          top: BorderSide(
                                                                              width: 1.0,
                                                                              color: activeIndex.value == index ? activeColor : defaultColor),
                                                                          bottom: BorderSide(width: 1.0, color: activeIndex.value == index ? activeColor : defaultColor)),
                                                                      borderRadius: const BorderRadius.all(Radius.circular(10))),
                                                                  child: Stack(
                                                                    children: [
                                                                      Column(
                                                                        mainAxisAlignment:
                                                                            MainAxisAlignment.center,
                                                                        children: [
                                                                          const Text(
                                                                            "服务费",
                                                                            style:
                                                                                TextStyle(fontSize: 16),
                                                                          ),
                                                                          const SizedBox(
                                                                            height:
                                                                                5,
                                                                          ),
                                                                          Row(
                                                                            mainAxisAlignment:
                                                                                MainAxisAlignment.center,
                                                                            children: [
                                                                              Text(
                                                                                "¥",
                                                                                style: TextStyle(fontWeight: FontWeight.bold, color: activeIndex.value == index ? activeColor : const Color(0xff333333)),
                                                                              ),
                                                                              Text(
                                                                                payList.value[index]["price"],
                                                                                style: TextStyle(color: activeIndex.value == index ? activeColor : const Color(0xff333333), fontWeight: FontWeight.bold, fontSize: 22),
                                                                              ),
                                                                            ],
                                                                          ),
                                                                          const SizedBox(
                                                                            height:
                                                                                5,
                                                                          ),
                                                                          Text(
                                                                            payList.value[index]["year"],
                                                                            style:
                                                                                const TextStyle(fontSize: 16),
                                                                          ),
                                                                        ],
                                                                      ),
                                                                      Visibility(
                                                                          visible:
                                                                              activeIndex.value == index,
                                                                          child: Align(
                                                                              alignment: Alignment.bottomRight,
                                                                              child: Container(
                                                                                width: 20,
                                                                                height: 20,
                                                                                alignment: Alignment.center,
                                                                                decoration: BoxDecoration(
                                                                                  borderRadius: const BorderRadius.only(
                                                                                    topLeft: Radius.circular(5),
                                                                                    topRight: Radius.circular(0),
                                                                                    bottomLeft: Radius.circular(0),
                                                                                    bottomRight: Radius.circular(5),
                                                                                  ),
                                                                                  color: activeColor,
                                                                                ),
                                                                                child: const Icon(
                                                                                  Icons.check,
                                                                                  size: 12,
                                                                                  color: Colors.white,
                                                                                ),
                                                                              )))
                                                                    ],
                                                                  )))
                                                        ],
                                                      ),
                                                    ),
                                                  );
                                                }).toList(),
                                              ],
                                            ),
                                          ),
                                        ),
                                        const SizedBox(
                                          height: 8,
                                        ),
                                        Container(
                                          width: double.infinity,
                                          height: 50,
                                          color: Colors.transparent,
                                          padding: const EdgeInsets.only(
                                              left: 10, right: 10),
                                          child: Row(
                                            mainAxisAlignment:
                                                MainAxisAlignment.spaceBetween,
                                            children: [
                                              Text(
                                                "证件审核费",
                                                style: TextStyle(
                                                    fontSize: 16,
                                                    fontWeight:
                                                        FontWeight.bold),
                                              ),
                                              Text(
                                                "¥" + auditFee,
                                                style: TextStyle(
                                                    fontSize: 16,
                                                    fontWeight:
                                                        FontWeight.bold),
                                              )
                                            ],
                                          ),
                                        ),
                                        buildLine(),
                                        Container(
                                          width: double.infinity,
                                          height: 50,
                                          color: Colors.transparent,
                                          padding: const EdgeInsets.only(
                                              left: 10, right: 10),
                                          child: Row(
                                            mainAxisAlignment:
                                                MainAxisAlignment.spaceBetween,
                                            children: [
                                              Text(
                                                "保证金",
                                                style: TextStyle(
                                                    fontSize: 16,
                                                    fontWeight:
                                                        FontWeight.bold),
                                              ),
                                              Text(
                                                "¥" + ensureFee,
                                                style: TextStyle(
                                                    fontSize: 16,
                                                    fontWeight:
                                                        FontWeight.bold),
                                              )
                                            ],
                                          ),
                                        ),
                                        buildLine(),
                                        SizedBox(
                                          height: 20,
                                        ),

                                        Container(
                                          width: double.infinity,
                                          // height: 50,
                                          color: Colors.transparent,
                                          padding: const EdgeInsets.only(
                                              left: 10, right: 10),
                                          child: Text(
                                            "请选择支付方式",
                                            style: TextStyle(
                                                fontSize: 16,
                                                fontWeight: FontWeight.bold),
                                          ),
                                        ),
                                        SizedBox(
                                          height: 20,
                                        ),
                                        Container(
                                          width: double.infinity,
                                          height: 50,
                                          color: Colors.transparent,
                                          padding: const EdgeInsets.only(
                                              left: 10, right: 10),
                                          child: buildNewRadioGrou(
                                              list: [
                                                {
                                                  "label": "余额支付",
                                                  "icon": "yue",
                                                  "value": "YE"
                                                },
                                                {
                                                  "label": "支付宝",
                                                  "icon": "zhifubao",
                                                  "value": "ALI"
                                                },
                                                {
                                                  "label": "微信支付",
                                                  "icon": "weixin",
                                                  "value": "WX"
                                                }
                                                // {"label": "积分支付", "value": "JF"},

                                                // {"label": "微信支付", "value": "WX"}
                                              ],
                                              widthFactor: 3,
                                              activeValue: payType.value,
                                              onChange: (value) {
                                                print("99999");
                                                payType.value = value;
                                                // onChangePayType(value)
                                                // payType.value = value;
                                                // if (onChange !=
                                                //     null) {
                                                //   onChange(value);
                                                // }
                                              }),
                                        ),

                                        // Container(
                                        //   width: double.infinity,
                                        //   child: Text(
                                        //     "请选择支付方式",
                                        //     style: TextStyle(
                                        //         fontSize: 16,
                                        //         fontWeight: FontWeight.bold),
                                        //   ),
                                        // ),

                                        SizedBox(
                                          height: 30,
                                        ),
                                        GestureDetector(
                                          onTap: () {
                                            isRead.value = !isRead.value;
                                          },
                                          child: Container(
                                            width: double.infinity,
                                            height: 50,
                                            alignment: Alignment.centerLeft,
                                            padding: const EdgeInsets.only(
                                                left: 15, right: 15),
                                            color: Colors.transparent,
                                            child: Row(
                                              children: [
                                                Container(
                                                  width: 18,
                                                  height: 18,
                                                  alignment: Alignment.center,
                                                  decoration: BoxDecoration(
                                                      color: isRead.value
                                                          ? Colors.red
                                                          : Color(0xffe6e0eb),
                                                      borderRadius:
                                                          BorderRadius.all(
                                                              Radius.circular(
                                                                  50))),
                                                  child: const Icon(
                                                    Icons.check,
                                                    size: 12,
                                                    color: Colors.white,
                                                  ),
                                                ),
                                                const SizedBox(
                                                  width: 10,
                                                ),
                                                const Text("已阅读并同意"),
                                                const Text(
                                                  "APP 协议",
                                                  style: TextStyle(
                                                      color: Color(0xff3c65f6)),
                                                ),
                                                const Text("和"),
                                                const Text(
                                                  "信息保护政策",
                                                  style: TextStyle(
                                                      color: Color(0xff3c65f6)),
                                                )
                                              ],
                                            ),
                                          ),
                                        )
                                      ],
                                    ),
                                  ))),
                          Container(
                            width: double.infinity,
                            height: 70,
                            color: Colors.white,
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Expanded(
                                    child: Container(
                                  width: double.infinity,
                                  height: double.infinity,
                                  child: Row(
                                    children: [
                                      SizedBox(
                                        width: 10,
                                      ),
                                      Text(
                                        "总计",
                                        style:
                                            TextStyle(color: Color(0xff919191)),
                                      ),
                                      SizedBox(
                                        width: 5,
                                      ),
                                      Text(
                                        "¥",
                                      ),
                                      Text(
                                        free.value,
                                        style: TextStyle(
                                            fontSize: 16,
                                            fontWeight: FontWeight.bold),
                                      )
                                    ],
                                  ),
                                )),
                                Container(
                                  width: 120,
                                  padding: const EdgeInsets.only(
                                      top: 13, bottom: 13, right: 10),
                                  height: double.infinity,
                                  child: buildButton(
                                      title: "立即支付",
                                      onClick: () async {
                                        if (!isRead.value) {
                                          EasyLoading.showToast("请阅读并勾选同意协议");
                                          return;
                                        }
                                        if (doOtherSubmit != null) {
                                          var id = showText(
                                              list[activeIndex.value]["id"]);
                                          var price = showText(
                                              list[activeIndex.value]["price"]);
                                          var res = await doOtherSubmit({
                                            "feeItems": [
                                              {
                                                "feeId": id,
                                                "feeType": "JOINSERVICE",
                                                "price": price
                                              },
                                              {
                                                "feeType": "AUDIT",
                                                "price": auditFee
                                              },
                                              {
                                                "feeType": "ENSURE",
                                                "price": ensureFee
                                              }
                                            ],
                                            "totalPrice": free.value
                                          });
                                          print("下单返回");
                                          print(res);

                                          if (payType.value == 'YE') {
                                            // 校验支付密码
                                            buildInputPassword(
                                                payType: "余额支付",
                                                price: free.value,
                                                onSuccess: (value) async {
                                                  print("输入的密码是===");
                                                  print(value);
                                                  if (passwordOkCallBack !=
                                                      null) {
                                                    passwordOkCallBack(
                                                        payType.value,
                                                        free.value,
                                                        res,
                                                        value);
                                                  }
                                                });

                                            GlobalPrefs.saveValue(
                                                "hasWindow", "NO");

                                            return;
                                          }

                                          if (okCallBack != null) {
                                            okCallBack(
                                                payType.value, free.value, res);
                                          }
                                          GlobalPrefs.saveValue(
                                              "hasWindow", "NO");
                                        }
                                        // if (doGetOrderFee != null) {
                                        //   var id = showText(
                                        //       list[activeIndex.value]["id"]);
                                        //   var res = await doGetOrderFee(id);
                                        //   print("查询价格");
                                        //   print(res);
                                        // }
                                      },
                                      borderRadius: 10,
                                      colors: [activeColor, activeColor]),
                                )
                              ],
                            ),
                          ),
                          Container(
                            width: double.infinity,
                            height: bottomHeight,
                            color: Colors.white,
                          )
                        ],
                      ),
                    )
                  ],
                )))),
        isDismissible: false, // 设置为false以禁止点击其他区域关闭
        enableDrag: false, // 设置为false以禁止拖动关闭
        isScrollControlled: true,
        // barrierColor: Colors.red,
        ignoreSafeArea: false,
        useRootNavigator: true);
  } else if (type == 'append') {
    free.value = showText(saleAmount);
    return Get.bottomSheet(
        WillPopScope(
            onWillPop: () async => false, //重点此举
            child: Container(
                decoration: const BoxDecoration(
                  color: Colors.transparent,
                  borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(20.0),
                      topRight: Radius.circular(20.0)), //圆角
                ),
                child: Obx(() => Column(
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: [
                        Container(
                          width: double.infinity,
                          height: 600,
                          color: Colors.white,
                          child: Column(
                            children: [
                              Container(
                                width: double.infinity,
                                padding: const EdgeInsets.only(
                                    left: 15, right: 15, top: 15, bottom: 15),
                                child: Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text(
                                      title,
                                      style: TextStyle(
                                          fontSize: 20,
                                          fontWeight: FontWeight.bold),
                                    ),
                                    GestureDetector(
                                      onTap: () {
                                        GlobalPrefs.saveValue(
                                            "hasWindow", "NO");
                                        Get.back();
                                      },
                                      child: const Text(
                                        "取消",
                                        style: TextStyle(
                                            color: Color(0xffaaaaaa),
                                            fontSize: 16),
                                      ),
                                    )
                                  ],
                                ),
                              ),
                              Expanded(
                                  child: Container(
                                      width: double.infinity,
                                      height: double.infinity,
                                      color: Colors.white,
                                      child: SingleChildScrollView(
                                        child: Column(
                                          children: [
                                            const SizedBox(
                                              height: 8,
                                            ),
                                            // Container(
                                            //   width: double.infinity,
                                            //   height: 50,
                                            //   color: Colors.transparent,
                                            //   padding:
                                            //       const EdgeInsets.only(left: 10, right: 10),
                                            //   child: const Row(
                                            //     mainAxisAlignment:
                                            //         MainAxisAlignment.spaceBetween,
                                            //     children: [
                                            //       Text(
                                            //         "证件审核费",
                                            //         style: TextStyle(
                                            //             fontSize: 16,
                                            //             fontWeight: FontWeight.bold),
                                            //       ),
                                            //       Text(
                                            //         "¥500",
                                            //         style: TextStyle(
                                            //             fontSize: 16,
                                            //             fontWeight: FontWeight.bold),
                                            //       )
                                            //     ],
                                            //   ),
                                            // ),
                                            // buildLine(),
                                            ...appendDetails.map((t) {
                                              return Container(
                                                width: double.infinity,
                                                padding: EdgeInsets.all(10),
                                                child: Row(
                                                  mainAxisAlignment:
                                                      MainAxisAlignment
                                                          .spaceBetween,
                                                  children: [
                                                    Text(
                                                      showText(t["name"]),
                                                      style: TextStyle(
                                                          fontWeight:
                                                              FontWeight.bold),
                                                    ),
                                                    Row(
                                                      children: [
                                                        Text(
                                                          "¥" +
                                                              showText(t[
                                                                  "unitPrice"]),
                                                          style: TextStyle(
                                                              fontWeight:
                                                                  FontWeight
                                                                      .bold,
                                                              color:
                                                                  Colors.red),
                                                        ),
                                                        SizedBox(
                                                          width: 20,
                                                        ),
                                                        Text("x" +
                                                            showText(t["num"])),
                                                      ],
                                                    )
                                                  ],
                                                ),
                                              );
                                            }).toList(),
                                            // Container(
                                            //   width: double.infinity,
                                            //   height: 50,
                                            //   color: Colors.transparent,
                                            //   padding: const EdgeInsets.only(
                                            //       left: 10, right: 10),
                                            //   child: Row(
                                            //     mainAxisAlignment:
                                            //         MainAxisAlignment
                                            //             .spaceBetween,
                                            //     children: [
                                            //       Text(
                                            //         "保证金",
                                            //         style: TextStyle(
                                            //             fontSize: 16,
                                            //             fontWeight:
                                            //                 FontWeight.bold),
                                            //       ),
                                            //       Text(
                                            //         "¥" + ensureFee,
                                            //         style: TextStyle(
                                            //             fontSize: 16,
                                            //             fontWeight:
                                            //                 FontWeight.bold),
                                            //       )
                                            //     ],
                                            //   ),
                                            // ),
                                            buildLine(),
                                            SizedBox(
                                              height: 10,
                                            ),

                                            Container(
                                              width: double.infinity,
                                              padding: EdgeInsets.only(
                                                  left: 10, right: 10),
                                              child: Row(
                                                mainAxisAlignment:
                                                    MainAxisAlignment
                                                        .spaceBetween,
                                                children: [
                                                  Text(
                                                    '优惠券',
                                                    style: TextStyle(
                                                        fontSize: 16,
                                                        fontWeight:
                                                            FontWeight.bold),
                                                  ),
                                                  Text(
                                                    "-¥" + reducePrice,
                                                    style: TextStyle(
                                                        fontSize: 16,
                                                        fontWeight:
                                                            FontWeight.bold),
                                                  )
                                                ],
                                              ),
                                            ),
                                            SizedBox(
                                              height: 10,
                                            ),
                                            buildLine(),
                                            SizedBox(
                                              height: 10,
                                            ),

                                            Container(
                                              width: double.infinity,
                                              // height: 50,
                                              color: Colors.transparent,
                                              padding: const EdgeInsets.only(
                                                  left: 10, right: 10),
                                              child: Text(
                                                "请选择支付方式",
                                                style: TextStyle(
                                                    fontSize: 16,
                                                    fontWeight:
                                                        FontWeight.bold),
                                              ),
                                            ),
                                            SizedBox(
                                              height: 20,
                                            ),
                                            Container(
                                              width: double.infinity,
                                              height: 50,
                                              color: Colors.transparent,
                                              padding: const EdgeInsets.only(
                                                  left: 10, right: 10),
                                              child: buildNewRadioGrou(
                                                  list: [
                                                    // {
                                                    //   "label": "微信支付",
                                                    //   "icon": "weixin",
                                                    //   "value": "WX"
                                                    // }
                                                    // {"label": "积分支付", "value": "JF"},
                                                    {
                                                      "label": "余额支付",
                                                      "icon": "yue",
                                                      "value": "YE"
                                                    },
                                                    {
                                                      "label": "支付宝",
                                                      "icon": "zhifubao",
                                                      "value": "ALI"
                                                    },
                                                    {
                                                      "label": "微信支付",
                                                      "icon": "weixin",
                                                      "value": "WX"
                                                    }
                                                  ],
                                                  widthFactor: 3,
                                                  activeValue: payType.value,
                                                  onChange: (value) {
                                                    print("99999");
                                                    payType.value = value;
                                                    // onChangePayType(value)
                                                    // payType.value = value;
                                                    // if (onChange !=
                                                    //     null) {
                                                    //   onChange(value);
                                                    // }
                                                  }),
                                            ),
                                            SizedBox(
                                              height: 30,
                                            ),
                                            // GestureDetector(
                                            //   onTap: () {
                                            //     isRead.value = !isRead.value;
                                            //   },
                                            //   child: Container(
                                            //     width: double.infinity,
                                            //     height: 50,
                                            //     alignment: Alignment.centerLeft,
                                            //     padding: const EdgeInsets.only(
                                            //         left: 15, right: 15),
                                            //     color: Colors.transparent,
                                            //     child: Row(
                                            //       children: [
                                            //         Container(
                                            //           width: 18,
                                            //           height: 18,
                                            //           alignment:
                                            //               Alignment.center,
                                            //           decoration: BoxDecoration(
                                            //               color: isRead.value
                                            //                   ? Colors.red
                                            //                   : Color(
                                            //                       0xffe6e0eb),
                                            //               borderRadius:
                                            //                   BorderRadius.all(
                                            //                       Radius
                                            //                           .circular(
                                            //                               50))),
                                            //           child: const Icon(
                                            //             Icons.check,
                                            //             size: 12,
                                            //             color: Colors.white,
                                            //           ),
                                            //         ),
                                            //         const SizedBox(
                                            //           width: 10,
                                            //         ),
                                            //         const Text("已阅读并同意"),
                                            //         const Text(
                                            //           "APP 协议",
                                            //           style: TextStyle(
                                            //               color: Color(
                                            //                   0xff3c65f6)),
                                            //         ),
                                            //         const Text("和"),
                                            //         const Text(
                                            //           "信息保护政策",
                                            //           style: TextStyle(
                                            //               color: Color(
                                            //                   0xff3c65f6)),
                                            //         )
                                            //       ],
                                            //     ),
                                            //   ),
                                            // )
                                          ],
                                        ),
                                      ))),
                              Container(
                                width: double.infinity,
                                height: 70,
                                color: Colors.white,
                                child: Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Expanded(
                                        child: Container(
                                      width: double.infinity,
                                      height: double.infinity,
                                      child: Row(
                                        children: [
                                          SizedBox(
                                            width: 10,
                                          ),
                                          Text(
                                            "总计",
                                            style: TextStyle(
                                                color: Color(0xff919191)),
                                          ),
                                          SizedBox(
                                            width: 5,
                                          ),
                                          Text(
                                            "¥",
                                          ),
                                          Text(
                                            free.value,
                                            style: TextStyle(
                                                fontSize: 16,
                                                fontWeight: FontWeight.bold),
                                          )
                                        ],
                                      ),
                                    )),
                                    Container(
                                      width: 120,
                                      padding: const EdgeInsets.only(
                                          top: 13, bottom: 13, right: 10),
                                      height: double.infinity,
                                      child: buildButton(
                                          title: "立即支付",
                                          borderRadius: 10,
                                          onClick: () {
                                            // if (!isRead.value) {
                                            //   EasyLoading.showToast(
                                            //       "请阅读并勾选同意协议");
                                            //   return;
                                            // }
                                            // if (doOtherSubmit != null) {
                                            // var id = ensureFeeId;
                                            // var res = await doOtherSubmit({
                                            //   "feeItems": [
                                            //     {
                                            //       "feeId": id,
                                            //       "feeType": "ENSURE",
                                            //       "price": ensureFee
                                            //     }
                                            //   ],
                                            //   "totalPrice": free.value
                                            // });
                                            // print("下单返回");
                                            // print(res);

                                            if (payType.value == 'YE') {
                                              // 校验支付密码
                                              buildInputPassword(
                                                  payType: "余额支付",
                                                  price: free.value,
                                                  onSuccess: (value) async {
                                                    print("输入的密码是===");
                                                    print(value);
                                                    if (passwordOkCallBack !=
                                                        null) {
                                                      passwordOkCallBack(
                                                          payType.value,
                                                          free.value,
                                                          {},
                                                          value);
                                                    }
                                                  });

                                              GlobalPrefs.saveValue(
                                                  "hasWindow", "NO");

                                              return;
                                            }

                                            if (okCallBack != null) {
                                              okCallBack(payType.value,
                                                  free.value, {});
                                            }

                                            GlobalPrefs.saveValue(
                                                "hasWindow", "NO");
                                            // }
                                          },
                                          colors: [activeColor, activeColor]),
                                    )
                                  ],
                                ),
                              ),
                              Container(
                                width: double.infinity,
                                height: bottomHeight,
                                color: Colors.white,
                              )
                            ],
                          ),
                        )
                      ],
                    )))),
        isDismissible: false, // 设置为false以禁止点击其他区域关闭
        enableDrag: false, // 设置为false以禁止拖动关闭
        isScrollControlled: true,
        // barrierColor: Colors.red,
        ignoreSafeArea: false,
        useRootNavigator: true);
  } else {
    free.value = ensureFee;
  }

  return Get.bottomSheet(
      WillPopScope(
          onWillPop: () async => false, //重点此举
          child: Container(
              decoration: const BoxDecoration(
                color: Colors.transparent,
                borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(20.0),
                    topRight: Radius.circular(20.0)), //圆角
              ),
              child: Obx(() => Column(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: [
                      Container(
                        width: double.infinity,
                        height: 600,
                        color: Colors.white,
                        child: Column(
                          children: [
                            Container(
                              width: double.infinity,
                              padding: const EdgeInsets.only(
                                  left: 15, right: 15, top: 15, bottom: 15),
                              child: Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Text(
                                    title,
                                    style: TextStyle(
                                        fontSize: 20,
                                        fontWeight: FontWeight.bold),
                                  ),
                                  GestureDetector(
                                    onTap: () {
                                      GlobalPrefs.saveValue("hasWindow", "NO");
                                      Get.back();
                                    },
                                    child: const Text(
                                      "取消",
                                      style: TextStyle(
                                          color: Color(0xffaaaaaa),
                                          fontSize: 16),
                                    ),
                                  )
                                ],
                              ),
                            ),
                            Expanded(
                                child: Container(
                                    width: double.infinity,
                                    height: double.infinity,
                                    color: Colors.white,
                                    child: SingleChildScrollView(
                                      child: Column(
                                        children: [
                                          Container(
                                            width: double.infinity,
                                            padding: EdgeInsets.all(15),
                                            child: Text(
                                              "由于你的销售累计金额已达 " +
                                                  saleAmount +
                                                  " 元需要补交 " +
                                                  ensureFee +
                                                  "元保证金",
                                              style: TextStyle(
                                                  color: Color(0xff969696)),
                                            ),
                                          ),
                                          const SizedBox(
                                            height: 8,
                                          ),
                                          // Container(
                                          //   width: double.infinity,
                                          //   height: 50,
                                          //   color: Colors.transparent,
                                          //   padding:
                                          //       const EdgeInsets.only(left: 10, right: 10),
                                          //   child: const Row(
                                          //     mainAxisAlignment:
                                          //         MainAxisAlignment.spaceBetween,
                                          //     children: [
                                          //       Text(
                                          //         "证件审核费",
                                          //         style: TextStyle(
                                          //             fontSize: 16,
                                          //             fontWeight: FontWeight.bold),
                                          //       ),
                                          //       Text(
                                          //         "¥500",
                                          //         style: TextStyle(
                                          //             fontSize: 16,
                                          //             fontWeight: FontWeight.bold),
                                          //       )
                                          //     ],
                                          //   ),
                                          // ),
                                          // buildLine(),
                                          Container(
                                            width: double.infinity,
                                            height: 50,
                                            color: Colors.transparent,
                                            padding: const EdgeInsets.only(
                                                left: 10, right: 10),
                                            child: Row(
                                              mainAxisAlignment:
                                                  MainAxisAlignment
                                                      .spaceBetween,
                                              children: [
                                                Text(
                                                  "保证金",
                                                  style: TextStyle(
                                                      fontSize: 16,
                                                      fontWeight:
                                                          FontWeight.bold),
                                                ),
                                                Text(
                                                  "¥" + ensureFee,
                                                  style: TextStyle(
                                                      fontSize: 16,
                                                      fontWeight:
                                                          FontWeight.bold),
                                                )
                                              ],
                                            ),
                                          ),
                                          buildLine(),
                                          SizedBox(
                                            height: 20,
                                          ),

                                          Container(
                                            width: double.infinity,
                                            // height: 50,
                                            color: Colors.transparent,
                                            padding: const EdgeInsets.only(
                                                left: 10, right: 10),
                                            child: Text(
                                              "请选择支付方式",
                                              style: TextStyle(
                                                  fontSize: 16,
                                                  fontWeight: FontWeight.bold),
                                            ),
                                          ),
                                          SizedBox(
                                            height: 20,
                                          ),
                                          Container(
                                            width: double.infinity,
                                            height: 50,
                                            color: Colors.transparent,
                                            padding: const EdgeInsets.only(
                                                left: 10, right: 10),
                                            child: buildNewRadioGrou(
                                                list: [
                                                  // {
                                                  //   "label": "微信支付",
                                                  //   "icon": "weixin",
                                                  //   "value": "WX"
                                                  // }
                                                  // {"label": "积分支付", "value": "JF"},
                                                  {
                                                    "label": "余额支付",
                                                    "icon": "yue",
                                                    "value": "YE"
                                                  },
                                                  {
                                                    "label": "支付宝",
                                                    "icon": "zhifubao",
                                                    "value": "ALI"
                                                  },
                                                  {
                                                    "label": "微信支付",
                                                    "icon": "weixin",
                                                    "value": "WX"
                                                  }
                                                ],
                                                widthFactor: 3,
                                                activeValue: payType.value,
                                                onChange: (value) {
                                                  print("99999");
                                                  payType.value = value;
                                                  // onChangePayType(value)
                                                  // payType.value = value;
                                                  // if (onChange !=
                                                  //     null) {
                                                  //   onChange(value);
                                                  // }
                                                }),
                                          ),
                                          SizedBox(
                                            height: 30,
                                          ),
                                          GestureDetector(
                                            onTap: () {
                                              isRead.value = !isRead.value;
                                            },
                                            child: Container(
                                              width: double.infinity,
                                              height: 50,
                                              alignment: Alignment.centerLeft,
                                              padding: const EdgeInsets.only(
                                                  left: 15, right: 15),
                                              color: Colors.transparent,
                                              child: Row(
                                                children: [
                                                  Container(
                                                    width: 18,
                                                    height: 18,
                                                    alignment: Alignment.center,
                                                    decoration: BoxDecoration(
                                                        color: isRead.value
                                                            ? Colors.red
                                                            : Color(0xffe6e0eb),
                                                        borderRadius:
                                                            BorderRadius.all(
                                                                Radius.circular(
                                                                    50))),
                                                    child: const Icon(
                                                      Icons.check,
                                                      size: 12,
                                                      color: Colors.white,
                                                    ),
                                                  ),
                                                  const SizedBox(
                                                    width: 10,
                                                  ),
                                                  const Text("已阅读并同意"),
                                                  const Text(
                                                    "APP 协议",
                                                    style: TextStyle(
                                                        color:
                                                            Color(0xff3c65f6)),
                                                  ),
                                                  const Text("和"),
                                                  const Text(
                                                    "信息保护政策",
                                                    style: TextStyle(
                                                        color:
                                                            Color(0xff3c65f6)),
                                                  )
                                                ],
                                              ),
                                            ),
                                          )
                                        ],
                                      ),
                                    ))),
                            Container(
                              width: double.infinity,
                              height: 70,
                              color: Colors.white,
                              child: Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Expanded(
                                      child: Container(
                                    width: double.infinity,
                                    height: double.infinity,
                                    child: Row(
                                      children: [
                                        SizedBox(
                                          width: 10,
                                        ),
                                        Text(
                                          "总计",
                                          style: TextStyle(
                                              color: Color(0xff919191)),
                                        ),
                                        SizedBox(
                                          width: 5,
                                        ),
                                        Text(
                                          "¥",
                                        ),
                                        Text(
                                          free.value,
                                          style: TextStyle(
                                              fontSize: 16,
                                              fontWeight: FontWeight.bold),
                                        )
                                      ],
                                    ),
                                  )),
                                  Container(
                                    width: 120,
                                    padding: const EdgeInsets.only(
                                        top: 13, bottom: 13, right: 10),
                                    height: double.infinity,
                                    child: buildButton(
                                        title: "立即支付",
                                        borderRadius: 10,
                                        onClick: () async {
                                          if (!isRead.value) {
                                            EasyLoading.showToast("请阅读并勾选同意协议");
                                            return;
                                          }
                                          if (doOtherSubmit != null) {
                                            var id = ensureFeeId;
                                            var res = await doOtherSubmit({
                                              "feeItems": [
                                                {
                                                  "feeId": id,
                                                  "feeType": "ENSURE",
                                                  "price": ensureFee
                                                }
                                              ],
                                              "totalPrice": free.value
                                            });
                                            print("下单返回");
                                            print(res);

                                            if (payType.value == 'YE') {
                                              // 校验支付密码
                                              buildInputPassword(
                                                  payType: "余额支付",
                                                  price: free.value,
                                                  onSuccess: (value) async {
                                                    print("输入的密码是===");
                                                    print(value);
                                                    if (passwordOkCallBack !=
                                                        null) {
                                                      passwordOkCallBack(
                                                          payType.value,
                                                          free.value,
                                                          res,
                                                          value);
                                                    }
                                                  });

                                              GlobalPrefs.saveValue(
                                                  "hasWindow", "NO");

                                              return;
                                            }

                                            if (okCallBack != null) {
                                              okCallBack(payType.value,
                                                  free.value, res);
                                            }

                                            GlobalPrefs.saveValue(
                                                "hasWindow", "NO");
                                          }
                                        },
                                        colors: [activeColor, activeColor]),
                                  )
                                ],
                              ),
                            ),
                            Container(
                              width: double.infinity,
                              height: bottomHeight,
                              color: Colors.white,
                            )
                          ],
                        ),
                      )
                    ],
                  )))),
      isDismissible: false, // 设置为false以禁止点击其他区域关闭
      enableDrag: false, // 设置为false以禁止拖动关闭
      isScrollControlled: true,
      // barrierColor: Colors.red,
      ignoreSafeArea: false,
      useRootNavigator: true);
}

getOrderFree({required Function doGetOrderFee, String id = ''}) async {
  final promise = Promise.run((resolve, reject) async {
    var res = await doGetOrderFee(id);
    resolve(res);
  });
  return promise;
}
